class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int n1 = nums.size();
        vector<int> ans(0);
        for (int i = 0; i < n1; i++){
            if (nums[i] != val){
                ans.push_back(nums[i]);
            }
        } 
        nums = ans;
        return ans.size();
    }
};